﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Collections;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class MP_FieldSpecifications : System.Web.UI.UserControl
    {
        private IFieldSpecDetailBLL detailBLL = new FieldSpecDetailBLL();
        private IFieldSpecificationBLL specBLL = new FieldSpecificationBLL();
        private PrimaryKeyBLL pkBLL = new PrimaryKeyBLL();

        private PrimaryKeyInfo pkInfo;   
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadDataGrid();
        }
        public void LoadDataGrid()
        {
            Nullable<int> FieldSeq = Session["FieldSeq"].ToString().Length > 0 ? Int32.Parse(Session["FieldSeq"].ToString()) : (int?)null;
            Nullable<int> ClassSeq = Session["ClassSeq"].ToString().Length > 0 ? Int32.Parse(Session["ClassSeq"].ToString()) : (int?)null;

            pkInfo = pkBLL.GetFieldSpecPK(FieldSeq, ClassSeq);
            if (pkInfo.Seq <= 0)
            {
                specBLL.Insert(Session["FieldSeq"].ToString()
                    , Session["ClassSeq"].ToString()
                    , "", 1);
            }
            pkInfo = pkBLL.GetFieldSpecPK(FieldSeq, ClassSeq);
            Session["FieldSpecSeq"] = pkInfo.Seq.ToString();
            IList<FieldSpecDetailInfo> Info = detailBLL.ListFieldSpecDetailsByFielsSpec(pkInfo.Seq.ToString());
            RadGrid1.DataSource = Info;
            RadGrid1.DataBind();
        }
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {

        }
    }
}